package com.eastfair.venuebooking.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 展会客户关系
 * </p>
 *
 * @author dqq
 * @date 2023-04-03
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ExhibitionCustomerCustomerIdentityEnum", description = "客户在该展会的身份 #{SPONSOR:主办方;UNDERTAKER:承办方-枚举")
public enum CustomerIdentityEnum implements BaseEnum {

    /**
     * SPONSOR="主办方"
     */
    SPONSOR("主办方"),
    /**
     * UNDERTAKER="承办方"
     */
    UNDERTAKER("承办方"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CustomerIdentityEnum match(String val, CustomerIdentityEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CustomerIdentityEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CustomerIdentityEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "SPONSOR,UNDERTAKER", example = "SPONSOR")
    public String getCode() {
        return this.name();
    }

}
